import {userlist} from "@/request/api.js"

export default {
    //定义数据
    state:{
       userList:[],
       page:1, //默认1
       size:6, //一页获取多少条
       count:1, //一共多少页
    },
    //获取数据
    getters:{
        get_userList(state){
            return state.userList
        }
    },
    //修改数据 -- 修改数据的唯一方式
    mutations:{
        mutation_userList(state,payload){
            state.userList = payload;
        }
    },
    //异步操作，发请求
    actions:{
        async action_userList({commit,state},payload){
            let res = await userlist({size:state.size,page:state.page});
            if(res.code == 200){
                commit("mutation_userList",res.list)
            }
        }
    },
    //开启命名空间
    namespaced:true
}